﻿using Identity.API.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Identity.API.Data
{
    public class ApplicationDbContextSeeds
    {
        public static async Task SeedAsync(UserManager<ApplicationUser> userManager,RoleManager<IdentityRole> roleManager)
        {
            await roleManager.CreateAsync(new IdentityRole { Name = "超级管理员" });

            var defaultUser = new ApplicationUser
            {
                UserName = "eshop",
                Email = "eshop@host.com"
            };

            await userManager.CreateAsync(defaultUser, "eshop");
            await userManager.AddToRoleAsync(defaultUser, "超级管理员");
        }
    }
}
